import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import JInput from '/@/components/Form/src/jeecg/components/JInput.vue';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '公司名称',
    align: "center",
    sorter: true,
    dataIndex: 'supplier_dictText',
    fixed: 'left',
    size:'small'
  },
  {
    title: '姓名',
    align: "center",
    sorter: true,
    dataIndex: 'realName',
    fixed: 'left',
    // size:'small',
    width:90
    
  },
  // {
  //   title: '人员属性(金科/厂商)',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'realName',
  //   fixed: 'left',
  //   size:'small'
  // },
  {
    title: '职级',
    align: "center",
    sorter: true,
    dataIndex: 'positionLevel_dictText',
    fixed: 'left',
    // size:'small'
    width:60
  },
  // {
  //   title: '外包人员电话',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'mobile'
  // },
  {
    title: '所属部门',
    align: "center",
    sorter: true,
    dataIndex: 'departId_dictText',
    fixed: 'left',
    size:'small'
  },
  {
    title: '项目',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText',
    fixed: 'left',
    size:'small'
  },
  {
    title: '合同开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '合同结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '入项时间',
    align: "center",
    sorter: true,
    dataIndex: 'entryTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '离项时间',
    align: "center",
    sorter: true,
    dataIndex: 'departureTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '离项倒计时(天)',
    align: "center",
    sorter: true,
    dataIndex: 'expireDay',
    customRender: ({ text }) => {
      const color = 'red';
      if(parseInt(text) < 10) {
        return render.renderTag(text, color);
      } else {
        return text;
      }
     
    }
  },
  {
    title: '订单状态',
    align: "center",
    sorter: true,
    dataIndex: 'ledgerStatus_dictText',
    customRender: ({ text }) => {
      if(text === '未到期') {
        return render.renderTag(text, 'green');
      } else if(text === '待续单') {
        return render.renderTag(text, 'yellow');
      } else {
        return render.renderTag(text, 'red');
      }
    }
  },
  {
    title: '人员状态',
    align: "center",
    sorter: true,
    dataIndex: 'outsourcePersonStatus_dictText',
    customRender: ({ text }) => {
      if(text === '在场') {
        return render.renderTag(text, 'green');
      } else if(text === '待离场') {
        return render.renderTag(text, 'yellow');
      } else if(text === '离场') {
        return render.renderTag(text, 'red');
      }
    }
  },
  {
    title: '订单编号',
    align: "center",
    sorter: true,
    dataIndex: 'orderNo'
  },
  {
    title: '项目经理',
    align: "center",
    sorter: true,
    dataIndex: 'pmId_dictText',
    fixed: 'left',
    width:120
  },
  {
    title: '项目经理电话',
    align: "center",
    sorter: true,
    dataIndex: 'pmMobile',
    width:130
  },
  {
    title: '质量对接人',
    align: "center",
    sorter: true,
    dataIndex: 'testLiaison_dictText',
    width:110
  },
  {
    title: '职场地点',
    align: "center",
    sorter: true,
    dataIndex: 'workPlace_dictText',
     width:110

  },
  
  // {
  //   title: '订单状态',
  //   align: "center",
  //   dataIndex: 'orderStatus_dictText'
  // },
];
//离场评价
export const departureEvaluateRecordColumns: JVxeColumn[] = [
  {
    title: '项目',
    key: 'projectId',
    type: JVxeTypes.selectSearch,
    dictCode:"tm_project,project_name,id",
    width:"200px",
    placeholder: '请输入${title}',
    defaultValue:'',
  },
  {
    title: '评价人',
    key: 'departureBy',
    type: JVxeTypes.input,
    width:"200px",
    placeholder: '请输入${title}',
    defaultValue:'',
  },
  {
    title: '离场状态',
    key: 'departureStatus',
    type: JVxeTypes.select,
    options:[],
    dictCode:"departure_status",
    width:"200px",
    placeholder: '请输入${title}',
    defaultValue:'',
  },
  {
    title: '离场时间',
    key: 'departureTime',
    type: JVxeTypes.date,
    width:"200px",
    placeholder: '请输入${title}',
    defaultValue:'',
  },
  {
    title: '离场评价',
    key: 'departureEvaluate',
    type: JVxeTypes.textarea,
    width:"200px",
    placeholder: '请输入${title}',
    defaultValue:'',
  },
]
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "供应商",
    field: 'supplier',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_supplier_manage,supplier_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "姓名",
    field: 'realName',
    component: 'JInput',
    //colProps: {span: 6},
  },
  {
    label: "职级",
    field: 'positionLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "position_level"
    },
    //colProps: {span: 6},
  },
  {
    label: "项目",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "项目经理",
    field: 'pmId',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "质量对接人",
    field: 'testLiaison',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "职场地点",
    field: 'workPlace',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_work_place,work_place,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "订单编号",
    field: 'orderNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "合同开始时间",
    field: 'contractStartTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "合同结束时间",
    field: 'contractEndTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "入项时间",
    field: 'entryTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "离项时间",
    field: 'departureTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "提前提醒",
    field: 'expireTipDay',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_expire_tips,expire_tip_name,expire_tip_tag"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '供应商',
    field: 'supplier',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_supplier_manage,supplier_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入供应商!'},
             ];
    },
  },
  {
    label: '姓名',
    field: 'realName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入姓名!'},
             ];
    },
  },
  {
    label: '职级',
    field: 'positionLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "position_level"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入职级!'},
             ];
    },
  },
  {
    label: '外包人员电话',
    field: 'mobile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入外包人员电话!'},
              { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
             ];
    },
  },
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '项目经理',
    field: 'pmId',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目经理!'},
             ];
    },
  },
  {
    label: '项目经理电话',
    field: 'pmMobile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目经理电话!'},
              { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
             ];
    },
  },
  {
    label: '质量对接人',
    field: 'testLiaison',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入质量对接人!'},
             ];
    },
  },
  {
    label: '职场地点',
    field: 'workPlace',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_work_place,work_place,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入职场地点!'},
             ];
    },
  },
  {
    label: '订单编号',
    field: 'orderNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入订单编号!'},
             ];
    },
  },
  {
    label: '合同开始时间',
    field: 'contractStartTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同开始时间!'},
             ];
    },
  },
  {
    label: '合同结束时间',
    field: 'contractEndTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同结束时间!'},
             ];
    },
  },
  {
    label: '入项时间',
    field: 'entryTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入入项时间!'},
             ];
    },
  },
  {
    label: '离项时间',
    field: 'departureTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入离项时间!'},
             ];
    },
  },
  {
    label: '预警日期',
    field: 'expireTipTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入预警日期!'},
             ];
    },
  },
  {
    label: '关联简历',
    field: 'resumeId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_resume,name,id"
    },
  },
  {
    label: '面试评价',
    field: 'interviewEvaluate',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  realName: {title: '姓名',order: 1,view: 'text', type: 'string',},
  positionLevel: {title: '职级',order: 2,view: 'list', type: 'string',dictCode: 'position_level',},
  projectId: {title: '项目',order: 4,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  pmId: {title: '项目经理',order: 5,view: 'sel_user', type: 'string',},
  workPlace: {title: '职场地点',order: 8,view: 'sel_search', type: 'string',dictTable: "tm_work_place", dictCode: 'id', dictText: 'work_place',},
  contractEndTime: {title: '合同结束时间',order: 11,view: 'date', type: 'string',},
  expireDay: {title: '到期时间(天)',order: 16,view: 'number', type: 'number',},
};
